<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%" max-height="600">
      <el-table-column prop="title" label="活动名称" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="addr" label="承办单位" show-overflow-tooltip>
      </el-table-column>
      <!-- <el-table-column prop="content" label="内容" show-overflow-tooltip>
      </el-table-column> -->
      <el-table-column prop="status" label="状态" width="100">
        <template slot-scope="scope">
          <p v-if="scope.row.status == 1">待评审</p>
          <p v-if="scope.row.status == 2">评审中</p>
          <p v-if="scope.row.status == 3">评审完成</p>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="des" label="描述" show-overflow-tooltip>
        <template slot-scope="scope">
          <p class="sheng">{{ scope.row.des || '--' }}</p>
        </template>
      </el-table-column> -->
      <el-table-column prop="startTime" label="起止时间" width="200">
        <template slot-scope="scope">
          <p
            >{{ scope.row.startTime | timecycleYMD }} ~
            {{ scope.row.endTime | timecycleYMD }}</p
          >
        </template>
      </el-table-column>
      <el-table-column label="操作" width="200">
        <template slot-scope="{ row }">
          <el-button-group>
            <el-button type="custom" size="mini" @click="handleManage(row)"
              >管理</el-button
            >
            <el-button type="primary" size="mini" @click="handleEdit(row)"
              >编辑</el-button
            >
            <el-button type="danger" size="mini" @click="handleDelete(row)"
              >删除</el-button
            >
          </el-button-group>
        </template>
      </el-table-column>
      <div slot="empty" class="emptyBg">
        <el-empty :image-size="200"></el-empty>
      </div>
    </el-table>
    <Pagination
      v-show="parseInt(pageObj.count) > 0"
      :total="parseInt(pageObj.count)"
      @change="getList"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
    />
  </div>
</template>
<script>
import {
  expertsReviewQuery,
  expertsReviewDelete,
} from '@/api/admin/audit/expertsReview.js'
import { setSession } from '@/utils/session'
import Bus from '@/utils/bus.js'
export default {
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 10,
      },
      tableData: [],
      pageObj: {},
    }
  },
  mounted() {
    this.getList()
    Bus.$on('refreshReviewList', (v) => {
      if (v) {
        Object.assign(this.listQuery, v)
      }
      this.getList()
    })
  },
  beforeDestroy() {
    Bus.$off('refreshReviewList')
  },
  methods: {
    async getList() {
      let res = await expertsReviewQuery(this.listQuery)
      this.tableData = res.data.data
      this.pageObj = res.data
    },
    //编辑
    handleEdit(row) {
      Bus.$emit('showDialogReviewAdd', row)
    },
    //评审团队
    handleManage(row) {
      setSession('reviewData', JSON.stringify(row))
      this.$router.push({ name: 'review-manage' })
    },
    //删除确认
    handleDelete(row) {
      this.$confirm('确定要删除吗?', '提示', {
        confirmButtonText: '删除',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.delete(row)
        })
        .catch(() => {})
    },
    //删除
    async delete(row) {
      let res = await expertsReviewDelete(row.id)
      if (!res || res.data.code != 0) return
      this.getList()
      this.$message({
        message: '操作成功',
        type: 'success',
      })
    },
  },
}
</script>